﻿using System.Data;
using Microsoft.ApplicationBlocks.Data;

namespace DataObject
{
    public class Action
    {
        public static IDataReader Reader_GetListPaging(string table, string order, string fieldList, string filter, int pageIndex, int pageSize)
        {
            return SqlHelper.ExecuteReader(Constants.ConnectionString, "Action", table, order, fieldList, filter, pageIndex, pageSize);
        }

        public static IDataReader Reader_GetListPaging(string table, string order, string filter, int pageIndex, int pageSize)
        {
            return SqlHelper.ExecuteReader(Constants.ConnectionString, "Action", table, order, "*", filter, pageIndex, pageSize);
        }

        public static int GetListPagingCount(string table, string filter)
        {
            return (int)SqlHelper.ExecuteScalar(Constants.ConnectionString, "Action_Count", table, filter);
        }
        
        public static DataTable DataTable_GetListPaging(string table, string order, string fieldList, string filter, 
                                                        int pageIndex, int pageSize, ref int totalRecords)
        {
            totalRecords = (int)SqlHelper.ExecuteScalar(Constants.ConnectionString, "Action_Count", table, filter);
            return SqlHelper.ExecuteDataset(Constants.ConnectionString, "Action", table, order, fieldList, filter, pageIndex, pageSize).Tables[0];
        }

        public static DataTable DataTable_GetListPaging(string table, string order, string fieldList, string filter,
                                                        int pageIndex, int pageSize)
        {            
            return SqlHelper.ExecuteDataset(Constants.ConnectionString, "Action", table, order, fieldList, filter, pageIndex, pageSize).Tables[0];
        }
    }
}
